package com.asf.sofom.repository;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.asf.sofom.domain.OEstatus;

@Repository(value="estatusDao")
public class JPAEstatus implements EstatusDao {
	
	private EntityManager em = null;
	
	@PersistenceContext
	public void setEntityManager(EntityManager em){
		this.em = em;
	}
	
	@Transactional(readOnly = true)
	@SuppressWarnings("unchecked")
	public List<OEstatus> getEstatus() {
		TypedQuery<OEstatus> tq = (TypedQuery<OEstatus>) em.createNativeQuery("Select * from personas_estatus", OEstatus.class);
		List<OEstatus> le = tq.getResultList();
		return le;
	}

	@Transactional(readOnly = false)
	public void setEstatus(OEstatus estatus) {
		em.merge(estatus);
	}
	

}
